﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace shutProcess.com.edwin.services
{
    public class ShutProcess
    {

        private String _exeName;
        //        private String _exeName = "RTX";
        private Process[] _pp;

        public bool ThreadFlag { get; set; }

        public string ExeName
        {
            get { return _exeName; }
            set { _exeName = value; }
        }

        public ShutProcess(string exeName)
        {
            ThreadFlag = false;
            this.ExeName = exeName;
            _pp = Process.GetProcesses();

        }


        public Boolean CheckEexeExists()
        {

            foreach (var p in _pp)
            {
                if (p.ProcessName.Equals(ExeName))
                {
                    Console.WriteLine(p.ProcessName);
                    return true;
                }

            }
            return false;
        }



        public Boolean DoShutProcess()
        {


            foreach (var p in _pp)
            {
                if (p.ProcessName.Equals(ExeName))
                {
                    p.Kill();
                    return true;
                }

            }
            return false;

        }


        public void RepeatShut()
        {






        }

    }
}
